

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Installation &mdash; pymunk 4.0.0 documentation</title>
    
    <link rel="stylesheet" href="_static/pymunk.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '4.0.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="shortcut icon" href="_static/pymunk_favicon.ico"/>
    <link rel="top" title="pymunk 4.0.0 documentation" href="index.html" />
    <link rel="next" title="API Reference" href="pymunk.html" />
    <link rel="prev" title="News" href="news.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pymunk.html" title="API Reference"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="news.html" title="News"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">pymunk 4.0.0 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<div class="admonition tip" id="id1">
<p class="first admonition-title">Tip</p>
<p class="last">You will find the latest version at
<a class="reference external" href="http://code.google.com/p/pymunk/downloads/list">http://code.google.com/p/pymunk/downloads/list</a></p>
</div>
<p>pymunk does not need to be installed. However, you might need to compile the
chipmunk library that pymunk uses internally if a precompiled library was not
included for your platform. The default pymunk distribution ships with at least
32-bit Windows and 32- and 64-bit Linux versions. But even if a compiled
library is not shipped you should not despair! It is very easy to compile
chipmunk as long as you have a gcc-compatible c compiler installed.</p>
<div class="section" id="without-installation">
<span id="without-install"></span><h2>Without installation<a class="headerlink" href="#without-installation" title="Permalink to this headline">¶</a></h2>
<p>You might want to test pymunk before you install it on your development
machine, or maybe decide to not install it at all. The easiest way to do this
is to download the source release of pymunk and extract the archive to the
folder where your code is and then tell python where to find it.</p>
<p>For example, lets say you have main.py and a folder named pymunk-3.0.0 that
contain the full source of pymunk (files, including setup.py, README.txt and
a folder named pymunk). Then you can add this before you include:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">sys</span>

<span class="n">current_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getcwd</span><span class="p">()</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> <span class="n">current_path</span><span class="p">,</span> <span class="s">&quot;pymunk-3.0.0&quot;</span> <span class="p">)</span> <span class="p">)</span>

<span class="kn">import</span> <span class="nn">pymunk</span>
</pre></div>
</div>
<p>For a working demo, check out the run.py file in the examples folder of
pymunk. It uses this exact technique to allow running the examples using the
pymunk located on level up.</p>
</div>
<div class="section" id="install-pymunk">
<h2>Install pymunk<a class="headerlink" href="#install-pymunk" title="Permalink to this headline">¶</a></h2>
<p>pymunk can be installed with pip install:</p>
<div class="highlight-python"><pre>&gt; pip install pymunk</pre>
</div>
<p>Another option is to install pymunk with one of the prebuilt installers if
available (Windows) or you can use the standard setup.py way:</p>
<div class="highlight-python"><pre>&gt; python setup.py install</pre>
</div>
<p>If you are on Mac OS X or Linux you will probably need to run as a privileged
user; for example using sudo:</p>
<div class="highlight-python"><pre>&gt; sudo python setup.py install</pre>
</div>
<p>Once installed you should be able to to import pymunk just as any other
installed library. pymunk should also work just fine with virtualenv in case
you want it installed in a contained environment.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The setup will not check if the correct Chipmunk library was included or
already compiled for you. It might be a good idea to first check that
pymunk works before you actually install it. See <a class="reference internal" href="#without-install"><em>Without installation</em></a></p>
</div>
</div>
<div class="section" id="compile-chipmunk">
<span id="id2"></span><h2>Compile Chipmunk<a class="headerlink" href="#compile-chipmunk" title="Permalink to this headline">¶</a></h2>
<p>If a compiled binary library of Chipmunk that works on your platform is not
included in the release you will need to compile Chipmunk yourself. Another
reason to compile chipmunk is if you want to run it in release mode to get
rid of the debug prints it generates.</p>
<p>To compile Chipmunk:</p>
<div class="highlight-python"><pre>&gt; python setup.py build_chipmunk</pre>
</div>
<p>On Windows you will need to use a gcc-compatible compiler. The precompiled
included windows binaries were compiled with a GCC installed from the TDM-GCC
package <a class="reference external" href="http://tdm-gcc.tdragon.net/">http://tdm-gcc.tdragon.net/</a> To set the compiler use the compiler
argument:</p>
<div class="highlight-python"><pre>&gt; python setup.py build_chipmunk --compiler=mingw32</pre>
</div>
<p>To compile Chipmunk in Release mode use the release argument (Useful to
avoid some debug prints and asserts):</p>
<div class="highlight-python"><pre>&gt; python setup.py build_chipmunk --release</pre>
</div>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt>Module <a class="reference internal" href="pymunkoptions.html#module-pymunkoptions" title="pymunkoptions"><tt class="xref py py-mod docutils literal"><span class="pre">pymunkoptions</span></tt></a></dt>
<dd>Options module that control runtime options of pymunk such as debug
settings. Use pymunkoptions together with release mode compilation to
remove all debugs prints.</dd>
</dl>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/pymunk_logo_sphinx.png" alt="Logo"/>
            </a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="readme.html">Readme</a></li>
<li class="toctree-l1"><a class="reference internal" href="news.html">News</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#without-installation">Without installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="#install-pymunk">Install pymunk</a></li>
<li class="toctree-l2"><a class="reference internal" href="#compile-chipmunk">Compile Chipmunk</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="pymunk.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorials.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="advanced.html">Advanced</a></li>
<li class="toctree-l1"><a class="reference external" href="http://code.google.com/p/pymunk/issues/list">Issue Tracker</a></li>
<li class="toctree-l1"><a class="reference external" href="http://code.google.com/p/pymunk/source/checkout">Source Repository</a></li>
<li class="toctree-l1"><a class="reference external" href="http://code.google.com/p/pymunk/downloads/list">Downloads</a></li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="news.html"
                        title="previous chapter">News</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="pymunk.html"
                        title="next chapter">API Reference</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/installation.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pymunk.html" title="API Reference"
             >next</a> |</li>
        <li class="right" >
          <a href="news.html" title="News"
             >previous</a> |</li>
        <li><a href="index.html">pymunk 4.0.0 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2013, Victor Blomqvist.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>